var slot:String;
var switchFlag:Boolean;
var roomTarget:String;
var roomSource:String;
var autoCount:Number;

function onEvtListInfo(evtObj)
{
	if (evtObj.channel!=Packages.model.UserProfile.RecordingCollabId) return;
	
	nameList=evtObj.param;
	var oldList=Packages.modula.task.Composition.accessList();
	Packages.modula.task.Composition.updateList(nameList);
	refreshPersonList(oldList, nameList);
}

function refreshPersonList(oldList:Array, userList:Array)
{
	var container=Packages.system.mlf.GateKeeper.scanElement(slot, "memberListContainer");
	for (var j=0; j<oldList.length; j++)
	{
		container[oldList[j]].removeMovieClip();
		mlf.mcmanager.component.IndexSlot.removeElement(slot, oldList[j]);
	}
	for (var i=0; i<userList.length; i++)
	{
		var personML2:String="";
		personML2+="<moonlight name='"+slot+"' template='"+slot+"-memberListContainer' uri='app/content/myReadjoy/recording/"+slot+".xml'>";
		personML2+="<portlet name='"+userList[i]+"' style='no'>";
		personML2+="<hotspot name='spot_"+userList[i]+"' x='5' y='5' height='20' width='130' alpha='0' />";
		personML2+="<media name='mic_"+userList[i]+"' type='image' src='app/img/mic.png' x='120' y='6' alpha='0' xscale='60' yscale='60'/>";
		personML2+="<textfield x='5' name='item' width='100' height='20' html='true' selectable='no'>"+userList[i]+"</textfield>";
		if (slot=="OnAir")
		{
			personML2+="<handler ins='"+slot+"-spot_"+userList[i]+"' type='onPress' value='spot' src='lib:notes.modula.task.Common.clickCollabMember' />";
		}
		personML2+="</portlet>";
		personML2+="</moonlight>";

		// Packages.log("personML2: "+personML2, "debug");

		mlf.gatekeeper.native.Caller.MLoader(null, null, null, null, personML2);
	}
}

function highlightSpeakerHolder(flag:Boolean)
{
	var args:Array=new Array();
	args.push(Packages.modula.task.Composition.speakerHolder);
	args.push(flag);
	updateCollab(this, "doHighlightSpeakerHolder", args);
}

function doHighlightSpeakerHolder(speakerHolder:String, flag:Boolean)
{
	Packages.log(Packages.model.UserProfile.data.nickName+".doHighlightSpeakerHolder: "+speakerHolder+" "+flag, "debug");
	
	if (speakerHolder==null || speakerHolder=="undefined") speakerHolder=Packages.modula.task.Composition.speakerHolder;
	var speakerHolder_spot=Packages.system.mlf.GateKeeper.scanElement(slot, "spot_"+speakerHolder);
	var selectedMicIcon=Packages.system.mlf.GateKeeper.scanElement(slot, "mic_"+speakerHolder);
	if (flag)
	{
		/*var nsDelay=Packages.modula.MicrophoneDevice.sub_ns.liveDelay;
		Packages.log("nsDelay: "+nsDelay, "debug");
		if (nsDelay==null)
		{
			nsDelay=0;
		}
		var color:Number=0x000000;
		if (nsDelay<500)
		{
			color=0x00ff00;
		}
		else if (nsDelay<1000)
		{
			color=0xffff00;
		}
		else color=0xff0000;*/
		// now color, but speed related flash effect indeed
		var mcColor=new Color(speakerHolder_spot);
		mcColor.setRGB(0x00ff00);
		speakerHolder_spot._alpha=30;

		if (Packages.modula.task.Processor.status=="recording")
		{
			selectedMicIcon._alpha=100;
		}

		if (speakerHolder==Packages.model.UserProfile.data.nickName) return;
		// start interval for checking sub_ns.liveDelay
		Packages.system.mlf.GateKeeper.addListener("onDelayIntervalEvent", this);
		var noticeEvent:Object=new Object();
		noticeEvent.type="onDelayIntervalEvent";
		noticeEvent.gap=5;
		noticeEvent.count=0;
		Packages.system.display.Timer.regNoticeEvent(noticeEvent);
	}
	else
	{
		speakerHolder_spot._alpha=0;

		selectedMicIcon._alpha=0;

		if (speakerHolder==Packages.model.UserProfile.data.nickName) return;
		// close interval for checking sub_ns.liveDelay
		Packages.system.mlf.GateKeeper.removeListener("onDelayIntervalEvent", this);
		Packages.system.display.Timer.removeNoticeEvent("onDelayIntervalEvent");
	}
	
}

function onDelayIntervalEvent(evt:Object)
{
	var speakerHolder=Packages.modula.task.Composition.speakerHolder;
	var speakerHolder_spot=Packages.system.mlf.GateKeeper.scanElement(slot, "spot_"+speakerHolder);
	var nsDelay=Packages.modula.MicrophoneDevice.sub_ns.liveDelay;
	Packages.log("onDelayIntervalEvent.nsDelay: "+nsDelay, "debug");
	if (nsDelay==null)
	{
		nsDelay=0;
	}
	var color:Number=0x000000;
	if (nsDelay<0.5)
	{
		color=0x00ff00;
	}
	else if (nsDelay<1)
	{
		color=0xffff00;
	}
	else color=0xff0000;
	// now color, but speed related flash effect indeed
	var mcColor=new Color(speakerHolder_spot);
	mcColor.setRGB(color);
}

function communicateStream(selectedUser:String, flag:Boolean)
{
	Packages.log("function communicateStream..."+selectedUser, "debug");

	// showMicIcon(selectedUser, flag);

	Packages.modula.MessageCenter.send(selectedUser+" {COMMUNICATE_MIC} "+flag, 1, 0);

	if (flag)
	{
		if (selectedUser==Packages.model.UserProfile.data.nickName)
		{
			Packages.modula.MicrophoneDevice.publishAttached(Packages.modula.task.Composition.audioId);
		}
		else
		{
			Packages.modula.MicrophoneDevice.subscribe(Packages.modula.task.Composition.audioId, true);
		}
		Packages.modula.task.Composition.speakerHolder=selectedUser;
	}
	else 
	{
		if (selectedUser==Packages.model.UserProfile.data.nickName)
		{
			Packages.modula.MicrophoneDevice.unpublishAttached();
		}
		else
		{
			Packages.modula.MicrophoneDevice.unsubscribe();
		}
		Packages.modula.task.Composition.speakerHolder=null;
	}
}

function clickCollabMember(param, data, slot)
{
	var index=param.indexOf("spot_");
	var selectedUser=param.substr(index+5);
	Packages.log("selectedUser: "+selectedUser, "debug");
	if (selectedUser==Packages.model.UserProfile.data.nickName)
	{
		// click self while not recording also check speakerHolder, communicate case
		if (Packages.modula.task.Processor.status=="recording") 
		{
			Packages.modula.MessageCenter.send("UNDER_RECORDING_NO_COMMUNICATE", 1, 0);
			return;
		}

		var args:Array=new Array();
		args.push(selectedUser);
		Packages.log("speakerHolder: "+Packages.modula.task.Composition.speakerHolder, "debug");
		if (Packages.modula.task.Composition.speakerHolder!=null)
		{	
			if (Packages.modula.task.Composition.speakerHolder==selectedUser)
			{
				// stop current communicating
				args.push(false);
				updateCollab(this, "communicateStream", args);
			}
			else
			{
				// no oper since no idle mic
				Packages.modula.MessageCenter.send("NO_IDLE_MICROPHONE", 1, 0);
				return;
			}
		}
		else
		{
			// start communicating
			args.push(true);
			updateCollab(this, "communicateStream", args);
		}
	}
	else
	{
		// click others if host, do sync with recording data model
		// updateCollab(this, "syncRecordingModel", syncArgs);
	}

}

function updateCollab(ins, func, args)
{
	Packages.system.mlf.Collab.updateInfo(ins, func, args, Packages.model.UserProfile.RecordingCollabId);
}

function stopCollabEnvironment()
{
	Packages.system.mlf.Collab.stopEngine(Packages.model.UserProfile.RecordingCollabId);
	Packages.system.mlf.GateKeeper.removeListener("onRTMPConnected", this);
	Packages.system.mlf.GateKeeper.removeListener("onEvtListInfo", this);
	delete slot;
	Packages.model.UserProfile.recordingCollabFlag=false;
}

function checkCollabEnvironment(slotName:String):Boolean
{
	slot=slotName;	// ?
	var userList=Packages.modula.task.Composition.accessList();
	if (userList.length>1)
	{
		// Packages.modula.task.Common.startCollabEnvironment(slotName);
		refreshPersonList(null, userList);
		return true;
	}
	else 
	{
		// append basic info with no collab env
		stopCollabEnvironment();
		Packages.model.UserProfile.RecordingCollabId=null;
		Packages.model.UserProfile.recordingCollabFlag=false;
		return false;
	}
}

function startCollabEnvironment(slotName:String)
{
	Packages.log("startCollabEnvironment...", "info");
	slot=slotName;
	// initialize the collaborative environment with the collab engine
	Packages.system.mlf.GateKeeper.addListener("onEvtListInfo", this);
	Packages.system.mlf.Collab.startEngine(Packages.model.UserProfile.RecordingCollabId);
	Packages.model.UserProfile.recordingCollabFlag=true;
	/* 2008-11-22 no effect, and nc.connected false, that's ok to create collab
	var nc=Packages.services.RTMPConn.getInstance();
	if (true)
	{
		Packages.log("nc.connected", "info");

		Packages.system.mlf.GateKeeper.addListener("onEvtListInfo", this);
		Packages.system.mlf.Collab.startEngine(Packages.model.UserProfile.RecordingCollabId);
		Packages.model.UserProfile.recordingCollabFlag=true;
	}
	else
	{
		Packages.log("nc.notconnected", "info");
		Packages.system.mlf.GateKeeper.addListener("onRTMPConnected", this);
	}*/
}

/*function onRTMPConnected()
{
	Packages.log("onRTMPConnected", "info");
	Packages.system.mlf.GateKeeper.removeListener("onRTMPConnected", this);
	Packages.system.mlf.GateKeeper.addListener("onEvtListInfo", this);
	Packages.system.mlf.Collab.startEngine(Packages.model.UserProfile.RecordingCollabId);
	Packages.model.UserProfile.recordingCollabFlag=true;
}*/

function sendMsg(content:String)
{
	var msg:String;
	
	if (content==null || content==Key.ENTER)
	{
		var messageInput_tf=Packages.system.mlf.GateKeeper.scanElement(slot, "messageInput");
		msg=messageInput_tf.text;
		messageInput_tf.text="";

		var messageInputHint=Packages.system.mlf.GateKeeper.scanDictionary(messageInput_tf, "MessageInputHint");
		if (messageInputHint.indexOf(msg)>-1)
		{
			return;
		}

		if (msg=="")
		{
			return;
		}
	}
	else msg=content;
	
	if (Packages.model.UserProfile.recordingCollabFlag)
	{
		var args=new Array();
		args.push(Packages.model.UserProfile.data.nickName);
		args.push(msg);
		updateCollab(this, "displayMessage", args);
	}
	else displayMessage(Packages.model.UserProfile.data.nickName, msg);

	
}
 
function displayMessage(name:String, msg:String)
{
	var messageArea_tf=Packages.system.mlf.GateKeeper.scanElement(slot, "messageArea");
	messageArea_tf.text+=name+": "+msg+"\n";
	messageArea_tf.scroll=messageArea_tf.maxscroll;
}

function switchRoom(name:String, src:String)
{
	// condition
	// checkPermission(name)
	// if true, go on
	// else return
	/*if (Packages.model.UserProfile.recordingCollabFlag)
	{
		if (!Packages.modula.task.Composition.host)
		{
			Packages.modula.MessageCenter.send("NO_HOST_RIGHT", 1, 0);
			return;
		}
	}*/
	
	roomTarget=name;
	roomSource=src;
	autoCount=5;

	var status:String=Packages.modula.task.Composition.currentTask.status;
	if (status==null) status="0";
	else status=status.toString();

	if (roomSource=="Prepairation" && roomTarget=="OnAir")
	{
		if (status=="0")
		{
			// initialize the task context
			recordTaskCreation();
		}
		/*else 
		{
			recordTaskPrepare();
		}*/
	}
	else if (roomSource=="Prepairation" && roomTarget=="PostProduction")
	{
		if (status=="2" && status=="3")
		{
			// allow
			// presets the audio related in Composition
		}
		else 
		{
			Packages.modula.MessageCenter.send("NO_RECORDING_COMPLETE", 1, 0);
			return;
		}
	}
	else if (roomSource=="Prepairation" && roomTarget=="Publish")
	{
		if (status=="3")
		{
			// allow
			// presets
		}
		else
		{
			Packages.modula.MessageCenter.send("NO_CONVERTING_COMPLETE", 1, 0);
			return;
		}
	}
	else if (roomSource=="OnAir" && roomTarget=="PostProduction")
	{
		if (Packages.components.content.myReadjoy.recording.OnAir.recordFlag)
		{
			Packages.modula.MessageCenter.send("ON_AIR", 1, 0);
			return;
		}

		if (!Packages.modula.task.Processor.recordedFlag)
		{
			Packages.modula.MessageCenter.send("NO_RECORDING_COMPLETE", 1, 0);
			return;
		}

		/*var progress=Packages.modula.RTxtReader.accessBlockInfo();
		if (progress.current==progress.total)
		{
			// allow
			Packages.modula.task.Processor.saveAudio("flv");
			Packages.modula.MessageCenter.send("SAVE_AUDIO_FLV", 1, 0);
			// updateTask also
		}
		else 
		{
			Packages.modula.MessageCenter.send("NO_RECORDING_COMPLETE", 1, 0);
			return;
		}*/
	}
	else if (roomSource=="OnAir" && roomTarget=="Publish")
	{
		Packages.modula.MessageCenter.send("NO_CONVERTING_OPERATION", 1, 0);
	}
	else if (roomSource=="PostProduction" && roomTarget=="Publish")
	{
		if (Packages.modula.task.Composition.filteredAudioId!=null)
		{
			Packages.modula.task.Processor.saveAudio("mp3");
		}
		else 
		{
			Packages.modula.MessageCenter.send("NO_CONVERTING_COMPLETE", 1, 0);
			return;
		}
	}
	else if (roomSource==roomTarget)
	{
		Packages.modula.MessageCenter.send("NO_CHANGE_ROOM", 1, 0);
		return;
	}
	else if (roomTarget=="Prepairation")
	{
		// reset all environment
		// return;
	}
	else 
	{
		Packages.modula.MessageCenter.send("NO_PERMISSION_FLOW", 1, 0);
		return;
	}

	if (!switchFlag)
	{
		startInterval();
		switchFlag=true;
	}
}

function onSwitchRoomEvent(evt:Object)
{
	autoCount--;
	var message:String=autoCount+" "+Packages.system.mlf.GateKeeper.scanDictionary(Packages.system.mlf.GateKeeper.scanElement(roomSource, "basic"), "SwitchCount");
	
	sendMsg(message);

	if (autoCount==0) 
	{
		closeInterval();
		switchFlag=false;
		if (Packages.model.UserProfile.recordingCollabFlag)
		{
			var args:Array=new Array();
			args.push(roomTarget);
			Packages.modula.task.Common.updateCollab(this, "doSwitchRoom", args);
		}
		else doSwitchRoom(roomTarget);
	}
}

function doSwitchRoom(room)
{
	Packages.components.SceneAgent.loadScene("content/myReadjoy/recording/"+room);
}

function startInterval()
{
	// Packages.log("startInterval.", "debug");
	
	Packages.system.mlf.GateKeeper.addListener("onSwitchRoomEvent", this);
	
	var noticeEvent:Object=new Object();
	noticeEvent.type="onSwitchRoomEvent";
	noticeEvent.gap=1;
	noticeEvent.count=0;
	Packages.system.display.Timer.regNoticeEvent(noticeEvent);
}

function closeInterval()
{
	// Packages.log("closeInterval.", "debug");
	
	Packages.system.mlf.GateKeeper.removeListener("onSwitchRoomEvent", this);
	Packages.system.display.Timer.removeNoticeEvent("onSwitchRoomEvent");
}

function prefetchCurrentTaskContext()
{
	var task=Packages.modula.task.Composition.currentTask;
	if (task!=null)
	{
		/*
		[DEBUG]: publishedAudioId: 2
		[DEBUG]: chapter.chapterId: 2
		[DEBUG]: recordTaskId: 2
		[DEBUG]: recordAlbum.recordAlbumId: 1
		[DEBUG]: status: 1
		[DEBUG]: updateTime: 2008-09-30 21:43:17.0
		[DEBUG]: latestAudioId: 2
		[DEBUG]: createTime: 2008-09-30 21:43:29.0
		*/
		var mess:String="";
		mess+="TASK_STATUS_"+task.status;
		mess+="\n"+"TASK_UPDATE_TIME"+task.updateTime+"\n"+"TASK_CREATE_TIME"+task.createTime;
		if (task.latestAudioId!=null) 
		{
			var data:Object=new Object();
			data.invokeCall="getLatestAudio";
			Packages.modula.RequestCommand.request("HTTP", "restlet/audio/"+task.latestAudioId, null, null, null, this, data);
		}
		else
		{
			mess+="\n"+"TASK_NO_AUDIO_CREATED";
		}
		Packages.components.content.myReadjoy.recording.Prepairation.showMessage(mess);
	}
	else 
	{
		var mess:String="NO_EXISTED_TASK";
		Packages.components.content.myReadjoy.recording.Prepairation.showMessage(mess);
	}
}

function getLatestAudio(result:Object)
{
	Packages.log("getLatestAudio: "+result, "debug");
	Packages.modula.task.Composition.latestAudio=result;

	if (result.subtype.toString()=="1")
	{
		Packages.modula.task.Composition.filteredAudioId=result.uuid;
	}
	/*
	[DEBUG]: flvAudioId: 32
	[DEBUG]: rating: 0
	[DEBUG]: uuid: 0c69400d-6b9e-4a97-845e-4ef7070e80a6
	[DEBUG]: memberId: 1
	[DEBUG]: name: mp3 source file
	[DEBUG]: subtype: 1
	[DEBUG]: sync.syncId: 32
	[DEBUG]: collabMemberIds: 
	[DEBUG]: ratingTotal: 0
	[DEBUG]: type: 1
	[DEBUG]: audioId: 33
	[DEBUG]: ratingCount: 0
	[DEBUG]: createTime: 2008-11-12 11:34:25.0
	[DEBUG]: recordTask.recordTaskId: 40
	[DEBUG]: sync.uuid: 19d6eef4-9393-4fb0-b40e-b0861e326f2d
	*/
	/*for (var a in result)
	{
		Packages.log(a+": "+result[a], "debug");
	}*/
	if (result["sync.uuid"]!=null)
	{
		var data:Object=new Object();
		data.invokeCall="getSyncFile";
		Packages.modula.RequestCommand.request("HTTP", "download?uuid="+result["sync.uuid"]+"&type=5&subtype=0", null, null, null, this, data);
	}
}

function getSyncFile(result:Object)
{
	Packages.log("getSyncFile: "+result, "debug");
	// Packages.modula.task.Composition.latestSyncFile=result;
	var syncFileObj:Object=new Object();
	var mlvStr:String=result.toString();

	var durationStartIndex=mlvStr.indexOf("duration")+10;
	var durationEndIndex=mlvStr.indexOf(" ", durationStartIndex)-1;
	syncFileObj.duration=mlvStr.substring(durationStartIndex, durationEndIndex);
	// Packages.log("syncFileObj.duration: "+syncFileObj.duration, "debug");
	var pointStartIndex=mlvStr.indexOf("point")+6;
	var pointEndIndex=mlvStr.indexOf("/point", pointStartIndex)-1;
	syncFileObj.point=mlvStr.substring(pointStartIndex, pointEndIndex).split(";");
	// Packages.log("syncFileObj.point: "+syncFileObj.point, "debug");
	var blockStartIndex=mlvStr.indexOf("blockMin")+10;
	var blockEndIndex=mlvStr.indexOf(">", blockStartIndex)-1;
	syncFileObj.block=mlvStr.substring(blockStartIndex, blockEndIndex);
	// Packages.log("syncFileObj.block: "+syncFileObj.block, "debug");

	Packages.modula.task.Composition.latestSyncFile=syncFileObj;

	var totalBlock=Packages.modula.RTxtReader.accessBlockInfo().total;

	var mess:String="";
	mess+="\n"+"RECORDING_DURATION"+syncFileObj.duration;
	mess+="\n"+"RECORDING_BLOCK"+syncFileObj.point.length+" "+" "+"RECORDING_TOTALBLOCK"+totalBlock+" "+"RECORDING_BLOCKMIN"+syncFileObj.block;

	Packages.components.content.myReadjoy.recording.Prepairation.showMessage(mess);
}

function recordTaskCreation()
{
	var roomId=Packages.model.UserProfile.RecordingCollabId;
	var params=roomId.split("_");
	
	var obj:Object=new Object();
	obj.recordAlbumId=params[0];;
	obj.chapterId=params[1];
	obj.memberId=Packages.model.UserProfile.data.memberId;

	Packages.modula.RequestCommand.request("REMOTING", "recordTaskCreate", obj, null, null, this, null);
}

function recordTaskPrepare()
{
	var obj:Object=new Object();

	obj.recordTaskId=Packages.modula.task.Composition.currentTask.recordTaskId.toString();

	Packages.modula.RequestCommand.request("REMOTING", "recordTaskPrepare", obj, null, null, this, null);
}

function setNewTaskId(id:String)
{
	Packages.modula.task.Composition.currentTask=new Object();
	Packages.modula.task.Composition.currentTask.recordTaskId=id;
}

function handleResponseResult(rsp:Object)
{
	if (rsp.service.method=="recordTaskCreate")
	{
		var rst=rsp.service.result;
		Packages.log("rsp.service.method: recordTaskCreate", "debug");
		for (var a in rst)
		{
			Packages.log(a+": "+rst[a], "debug");
		}
		if (Packages.model.UserProfile.recordingCollabFlag)
		{
			var args=new Array();
			args.push(rsp.service.result.returnObj);
			updateCollab(this, "setNewTaskId", args);
		}
		else setNewTaskId(rsp.service.result.returnObj);
	}
	else if (rsp.service.method=="recordTaskPrepare")
	{
		if (rsp.service.result.returnObj==0)
		{
			Packages.modula.MessageCenter.send("RECORD_TASK_PREPARED", 1, 0);
		}
		else
		{
			Packages.modula.MessageCenter.send("RECORD_TASK_PREPARED_ERROR"+rsp.service.result.returnObj, 1, 0);
		}
	}

	if (rsp.component.data.invokeCall!=null)
	{
		if (rsp.component.data.invokeArgs==null)
		{
			rsp.component.data.invokeArgs=new Array();
		}
		rsp.component.data.invokeArgs.push(rsp.service.result);
		this[rsp.component.data.invokeCall].apply(this, rsp.component.data.invokeArgs);
	}
}

function establishAudioChannel()
{
	var execFlag:Boolean=false;
	
	if (Packages.model.Context.activeContent._name=="Prepairation")
	{
		execFlag=true;
	}
	else if (Packages.model.UserProfile.recordingCollabFlag)
	{
		// in collab env, not host return, wait the generated audioId from host
		if (!Packages.modula.task.Composition.host) execFlag=false;
		else 
		{
			execFlag=true;
			sendMsg("WAITTING_HOST_REQUEST_AUDIO_ID");
		}
	}
	else execFlag=true;

	Packages.log("execFlag: "+execFlag, "debug");

	if (!execFlag) return;
	
	Packages.log("RTMPConn.nc.connected: "+Packages.services.RTMPConn.nc.connected, "debug");
	
	if (Packages.services.RTMPConn.nc.connected) generateAudioId();
	else 
	{
		Packages.system.mlf.GateKeeper.addListener("onRTMPConnected", this);
	}	
}

function onRTMPConnected()
{
	Packages.system.mlf.GateKeeper.removeListener("onRTMPConnected", this);
	generateAudioId();
}

function generateAudioId()
{
	Packages.log("generateAudioId.call ", "debug");
	
	var item=new Object();
	item.type="generateUuid";
	item.param=new Object();
	item.result=new Object();
	item.result.owner=this;
	item.result.onResult=function(res)
	{
		Packages.log("generateAudioId.onResult: "+res.returnObj, "debug");
		if (res.returnObj!=null)
		{
			if (Packages.model.Context.activeContent._name=="Prepairation")
			{
				// prepairation, seperated env
				this.owner.generatedAudioId(res.returnObj);
			}
			else if (Packages.model.UserProfile.recordingCollabFlag)
			{
				// [host]collab env, tell all members
				var args=new Array();
				args.push(res.returnObj);
				this.owner.updateCollab(this.owner, "generatedAudioId", args);
			}
			else
			{
				// solo env
				this.owner.generatedAudioId(res.returnObj);
			}
			
		}
	}	
	Packages.system.mlf.GateKeeper.rtmpCaller(item);
}

function generatedAudioId(id:String)
{
	Packages.log("generatedAudioId: "+id, "debug");
	Packages.modula.task.Composition.audioId=id;
	Packages.modula.MessageCenter.send("GENERATE_AUDIO_ID_COMPLETE", 1, 0);
}